/*
 * @Copyright: (C) 2019 Zhang Rida. All rights reserved.
 *
 * @Author: Zhang Rida
 * @Email: 215154317@qq.com
 * @FilePath: \WEILA_8910_PROJECT\Third-party\weilasdk\src\wlsdk\src\wl_http_client.h
 * @Date: 2021-02-27 17:08:35
 * @Description:
 *
 * @LastEditors: Zhang Rida
 * @LastEditTime: 2021-05-13 19:25:18
 */
#ifndef _HTTP_CLIENT_H
#define _HTTP_CLIENT_H

#include "wl_osal.h"
#include "wl_inner.h"

#ifdef __cplusplus
extern "C" {
#endif

#define HTTP_CLIENT_REQUEST_TIMEOUT_5 5
#define HTTP_CLIENT_REQUEST_TIMEOUT_10 10
#define HTTP_CLIENT_REQUEST_TIMEOUT_15 15
#define HTTP_CLIENT_REQUEST_TIMEOUT_30 30
#define HTTP_CLIENT_REQUEST_TIMEOUT_60 60

typedef enum {
    HTTP_CLIENT_CONTENT_NONE = 0,
    HTTP_CLIENT_CONTENT_JSON,
    HTTP_CLIENT_CONTENT_XML,
    HTTP_CLIENT_CONTENT_BINARY,
    HTTP_CLIENT_CONTENT_FILE_PATH
} wl_http_client_content_type;

typedef void (*wl_http_client_callback)(wl_uint32 result,
                                     wl_char*  content,
                                     wl_uint32 content_len,
                                     wl_uint32 content_type,
                                     void*     context);

wl_int32 wl_http_client_init(void);
wl_int32 wl_http_client_end(void);

wl_int32 wl_http_client_get(wl_char* url, wl_uint32 timeout, wl_http_client_callback callback, void* context);
wl_int32 wl_http_client_get_file(wl_char* url, wl_uint32 timeout, wl_http_client_callback callback, void* context);
wl_int32 wl_http_client_get_file_with_path(wl_char*             url,
                                        wl_char*             path,
                                        wl_uint32            timeout,
                                        wl_http_client_callback callback,
                                        void*                context);
wl_int32 wl_http_client_post(wl_char*             url,
                          wl_uint32            timeout,
                          wl_char*             content,
                          wl_uint32            content_len,
                          wl_uint32            content_type,
                          wl_http_client_callback callback,
                          void*                context);

wl_int32 wl_http_process_message(wl_task_message* message);
#ifdef __cplusplus
}
#endif
#endif
